<template>
  <view class="fixed_box" @click.stop="closeSoldForFn">
    <view class="publicPopup_box">
      <div class="public_msg_box">
        <div class="public_titName_box">提示</div>
        <div class="public_text_box">你已帮卖过该内容</div>
        <button class="iKnow_btn" hover-class="hover" @click.stop="goToHelpSell">前往我帮卖的内容</button>
      </div>
    </view>
  </view>
</template>

<script>
  import mini from "@/api/mini.js";

  export default {
    props: {
      soldForHelpSellId: {
        type: String,
        default: ''
      }
    },
    methods: {
      goToHelpSell () {
        let routeArr = getCurrentPages()
        if (routeArr[routeArr.length-1].route==='pagesB/dynamic/videoDetail' || routeArr[routeArr.length-1].route==='pagesB/dynamic/graphicsDetail') { //本身在视频流页面刷新数据即可
          this.$emit('refreshOwnFn',this.soldForHelpSellId)
        } else {
          try {
            // 多个地方调用，不方便传参判断动态类型是否为图片，故而调此接口，如果嫌弃跳转页面速度慢，需改为传参模式
            mini.getHomeDynamics({type: 1, currentPage: 1, pageSize: 1, dynamicId: this.soldForHelpSellId}).then(res=>{
              const { records } = res.data
              if(records.length && records[0].mediaType === 1){
                this.navigateTo({url: `/pagesB/dynamic/graphicsDetail?dynamicId=${this.soldForHelpSellId}&type=1`})
              }else{
                this.navigateTo({url: `/pagesB/dynamic/videoDetail?dynamicId=${this.soldForHelpSellId}&type=1`})
              }
            })
          } catch (error) {
            this.navigateTo({url: `/pagesB/dynamic/videoDetail?dynamicId=${this.soldForHelpSellId}&type=1`})
          }
        }
        this.closeSoldForFn()
      },
      closeSoldForFn() {
        this.$emit('closeSoldForFn')
      }
    }
  }
</script>

<style lang="scss" scoped>
.publicPopup_box {
  width: 622rpx;
  .public_text_box {
    line-height: 88rpx;
  }
  .iKnow_btn {
    margin-top: 48rpx;
  }
}
</style>